<%@page import="java.text.SimpleDateFormat"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!doctype html>
<html>
	<head>
		<title>平台水位控制</title>
		<base href="<%=basePath%>" />
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<meta name="renderer" content="webkit">
		<meta http-equiv="Cache-Control" content="no-siteapp" />
		<meta name="apple-mobile-web-app-title" content="Amaze UI" />
		<link rel="stylesheet" href="layui/css/layui.css" media="all"> <!-- 适应所有设备 -->
		<style type="text/css">
		</style>
	</head>
	<% String nowDay = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); %>
	<body>
	
	    <form class="layui-form" onsubmit='return false'>
	    <br/>
	    <table class="layui-hide" id="platform" lay-filter="platform"></table>
	    </form>
	    <script type="text/html" id="modify">
          <a class="layui-btn layui-btn-xs " lay-event="bonus">立刻分红</a>
        </script>
        
        <script type="text/html" id="PrizePoolShareBonusBoundary">
            {{#  }}
                <span class="layui-badge layui-bg-green">{{ d.PrizePoolShareBonusBoundary }}</span>
            {{#  }}
        </script>
        
	    <script type="text/html" id="PrizePoolShareBonusCD">
            {{#  d.PrizePoolShareBonusCD = d.PrizePoolShareBonusCD/60 }}
                <span class="layui-badge layui-bg-green">{{ d.PrizePoolShareBonusCD }}</span>
            {{#  }}
        </script>
        
        <script type="text/html" id="PrizePoolShareBonusRate">
            <span class="layui-badge layui-bg-green">{{ d.PrizePoolShareBonusRate }}</span>
        </script>
        
        <script type="text/html" id="PrizePoolShareBonusAdditionRate">
            <span class="layui-badge layui-bg-green">{{ d.PrizePoolShareBonusAdditionRate }}</span>
        </script>
	    
	    <script type="text/html" id="GlobalGameDifficultyLevel">
            {{#  if(d.GlobalGameDifficultyLevel == 0){ }}
                <span>地域灾难</span>
            {{#  } else if(d.GlobalGameDifficultyLevel == 1){ }}
                <span>非常困难</span>
            {{#  } else if(d.GlobalGameDifficultyLevel == 2){ }}
                <span>困难</span>
            {{#  } else if(d.GlobalGameDifficultyLevel == 3){ }}
                <span>中等</span>
            {{#  } else if(d.GlobalGameDifficultyLevel == 4){ }}
                <span>简单</span>
            {{#  } else if(d.GlobalGameDifficultyLevel == 5){ }}
                <span>分红</span>
            {{#  } else if(d.GlobalGameDifficultyLevel == 6){ }}
                <span>大富豪</span>
            {{#  } }}
        </script>
	    
	    <script src="js/jquery.min.js"></script>
		<script src="layui/layui.js"></script>
		<script src="js/common/monitor_back.js"></script>

		<script>
		    layui.use(['layer','form','table'],function(){
		    	var layer = layui.layer,
		    	    form  = layui.form,
		    	    table = layui.table;
		    	
		    	layer.config({
					extend: 'MySkin/style.css'
				});
		    	
		    	table.render({
		    		elem:'#platform',
		    		url:'platform/Bonussettingslist',
		    		method:'post',
		    		skin: 'row',
		    		even: true,
		    		page : false,//分页
		    		id:'AllTable',
		    		request:{
						pageName:'PageIndex',
						limitName:'PageCount'
					},
		    		cols:[[
		    			{field:'GlobalPrizePool',title:'平台水位',style:'color:#d71345',templet:'#GlobalPrizePool',event:'setGlobalPrizePool'},
		    			{field:'GlobalGameDifficultyLevel',title:'难度档位',style:'color:#ed1941',templet:'#GlobalGameDifficultyLevel'},
		    			{field:'PrizePoolShareBonusBoundary',title:'分红线水位线',style:'color:#d71345',templet:'#PrizePoolShareBonusBoundary',event:'PrizePoolShareBonusBoundary'},
		    			{field:'PrizePoolShareBonusCD',title:'分红间隔(分)',style:'color:#f05b72',templet:'#PrizePoolShareBonusCD',event:'PrizePoolShareBonusCD'},
		    			{field:'PrizePoolShareBonusRate',title:'分红比例',style:'color:#1d953f',templet:'#PrizePoolShareBonusRate',event:'PrizePoolShareBonusRate'},
		    			{field:'PrizePoolShareBonusAdditionRate',title:'个人奖池临时增加比例',style:'color:#1d953f',templet:'#PrizePoolShareBonusAdditionRate',event:'PrizePoolShareBonusAdditionRate'},
		    			{field:'PrizePoolNextShareBonusTime',title:'下次分红时间显示',style:'color:#009ad6'},
		    			{fixed:'right',title:'操作 ',toolbar: '#modify'},
		    			]],
						response : {
							statusCode : 200
						//重新规定成功的状态码为 200，table 组件默认为 0
						},
						parseData : function(res) { //将原始数据解析成 table 组件所规定的数据
							return {
								"code" : res.status, //解析接口状态
								"msg" : res.message, //解析提示文本
								"count" : res.count, //解析数据长度
								"data" : res.data
							//解析数据列表
							};
						}
		    	});
		    	
		    	//监听行工具事件
		    	table.on('tool(platform)',function(obj){
					if (history.state == null){
						pushHistory();
					}
		    		var data = obj.data,
		    		layEvent = obj.event;
		    		if(layEvent === 'bonus'){
		    			$.ajax({
		    				type:'POST',
		    				url:'platform/immediately',
		    				async:true,
		    				success:function(resp){
		    					if(resp == "success"){
		    						layer.msg("设置成功",{icon:1});
		    						setTimeout(function (){
			                            layui.table.reload('AllTable',{});
									}, 1000);
		    					}else{
		    						layer.msg(resp,{icon:2});
		    					}
		    				},
							cancel:function () {
								window.history.back();
							}
		    			});
		    		}else if(layEvent === 'PrizePoolShareBonusBoundary'){
		    			var index = layer.open({
		    				type:2,
		    				shadeClose:true,
		    				shade:0.5,
		    				area:['500px','250px'],
		    				title:'修改自动分红水位线',
		    				skin: 'layer-ext-yourskin',
		    				content:'platform/sharebonuswaterline',
		    				success:function(layero,index){
		    					var body = layer.getChildFrame("body",index);
		    				},
							cancel:function () {
								window.history.back();
							}
		    			});
		    		}else if(layEvent === 'PrizePoolShareBonusCD'){
		    			var index = layer.open({
		    				type:2,
		    				shadeClose:true,
		    				shade:0.5,
		    				area:['500px','250px'],
		    				title:'修改分红间隔(分钟)',
		    				skin: 'layer-ext-yourskin',
		    				content:'platform/changebonustimeview',
		    				success:function(layero,index){
		    					var body = layer.getChildFrame("body",index);
		    				},
							cancel:function () {
								window.history.back();
							}
		    			});
		    		}else if(layEvent === 'PrizePoolShareBonusRate'){
		    			var index = layer.open({
		    				type:2,
		    				shadeClose:true,
		    				shade:0.5,
		    				area:['500px','250px'],
		    				title:'修改分红比例',
		    				skin: 'layer-ext-yourskin',
		    				content:'platform/changebonusproportionview',
		    				success:function(layero,index){
		    					var body = layer.getChildFrame("body",index);
		    				},
							cancel:function () {
								window.history.back();
							}
		    			});
		    		}else if(layEvent === 'PrizePoolShareBonusAdditionRate'){
		    			var index = layer.open({
		    				type:2,
		    				shadeClose:true,
		    				shade:0.5,
		    				area:['500px','250px'],
		    				title:'修改个人奖池临时比例',
		    				skin: 'layer-ext-yourskin',
		    				content:'platform/changetemporaryview',
		    				success:function(layero,index){
		    					var body = layer.getChildFrame("body",index);
		    				},
							cancel:function () {
								window.history.back();
							}
		    			});
		    		}
		    	});
		    	
		    	//定时刷新数据
				setInterval(function(){
					table.reload('AllTable', {});
	              },300000);
		    	
				
				//根据条件查询表格数据重新加载
				var active = {
					reload: function() {
						//获取用户名
						//执行重载
						table.reload('AllTable', {});
						return false;
					}
				};
				//点击搜索按钮根据用户名称查询
				$('#SelectOrder').on('click',
					function() {
						var type = $(this).data('type');
						active[type] ? active[type].call(this) : '';
					});
		    	
		    });
		</script>
    </body>
</html>